package huawei.nk;


import java.util.Scanner;

/**
 * 每隔两个数,删除
 */
public class NKLinkDel {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        while (s.hasNextInt()){
            System.out.println(del(s.nextInt()));
        }
    }
    static class ListNode{
        int val;
        ListNode next;
        ListNode(int n){
            val = n;
        }

    }
    public static int del(int n){
            ListNode head = new ListNode(0);
            ListNode tmp = head;
            for (int i = 1; i < n; i++) {
                tmp.next=new ListNode(i);
                tmp=tmp.next;
            }
            tmp.next=head;

            while (n>1){
                ListNode before = head.next;
                ListNode after = before.next.next;
                before.next=after;
                head=after;
                n--;
            }
        return head.val;
    }
}
